package com.example.service;

import com.example.pojo.Article;
import com.example.repository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class ArticleService {

    @Autowired
    private ArticleRepository articleRepository;


    public Article save(Article article) {
//        article.setId(UUID.randomUUID().toString());
        Article save = articleRepository.save(article);
        System.out.println(save.toString());
        return save;
    }

    public Page<Article> findByKey(String key, Pageable pageable) {
        Page<Article> byTitleOrContent = articleRepository.findByTitleOrContent(key, key, pageable);
        return byTitleOrContent;
    }


}
